package com.wenhao.dewu;

/**
 * @author Wenhao Tong
 * @create 2021-08-29 19:20
 */
public class Main2 {
    public static void main(String[] args) {
        findLongest("1AB2345CD",9,"12345EF",7);
    }

    public static int findLongest(String A, int n, String B, int m) {
        // write code here
        int[][] dp = new int[n][m];
        int max = 0;
        for (int i = 0;i < n;i++) {
            int count = 0;
            for (int j = 0;j < m && j + i < n;j++) {
                char b = B.charAt(j);
                char a = A.charAt(i + j);
                if (a == b && (j + 1 == m || b + 1 == B.charAt(j + 1)) && (a + 1 == n || a + 1 == A.charAt(j + i + 1))) {
                    count++;
                }
            }
            max = Math.max(count,max);
        }
        return max;
    }
}
